home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / nktools.zip / ERRMSG.ASM < prev    next >
Assembly Source File  |  1991-02-11  |  22KB  |  631 lines

  1. ;======================================================================
  2. ; MODULE NAME:  ErrMsg
  3. ; DEPENDENCIES: System
  4. ; LAST MOD ON:  9102.11
  5. ; PROGRAMMER:   Naoto Kimura
  6. ;
  7. ;     This unit was made for those who want to have more descriptive
  8. ; error messages from Turbo Pascal programs.  The error messages will
  9. ; be sent to the standard DOS output file.  The "EndWait" unit is
  10. ; installed for version 5 of the compiler.
  11. ;
  12. ; MODIFICATION HISTORY:
  13. ; 9004.08       Naoto Kimura
  14. ;               Initial version created
  15. ; 9005.11       Naoto Kimura
  16. ;               Added error message for version 5.5
  17. ; 9006.04       Naoto Kimura
  18. ;               Made minor adjustment to code, shrinking it by a few
  19. ;               bytes.
  20. ; 9102.11       Naoto Kimura
  21. ;               Added new error messages for version 6.0
  22. ;=====================================================================
  23. .MODEL TPASCAL
  24. LOCALS
  25.  
  26. DATASEG
  27.  
  28. ; From System unit
  29. EXTRN    ExitProc:DWORD,ErrorAddr:DWORD,ExitCode:WORD
  30. ; Local to unit
  31. EXTRN    ExitSave:DWORD,VerboseMsg:BYTE
  32.  
  33. BufferSize    EQU    8
  34. Buffer        DB    BufferSize DUP (?)
  35.  
  36. Msg1        DW    ?
  37. Msg1Len        DW    ?
  38. Msg2        DW    ?
  39. Msg2Len        DW    ?
  40.  
  41. CODESEG
  42.  
  43. Copyright    DB    'ERRMSG.TPU                copyright '
  44.         DB    'Naoto Kimura (02/11/91)';
  45.  
  46. NewLine        DB    13,10
  47. NewLineLen    =    $-NewLine
  48.  
  49. UnknownMsg1    DB    'Unknown error code ('
  50. UnknownMsg1Len    =    $-UnknownMsg1
  51. UnknownMsg2    DB    ')',13,10
  52. UnknownMsg2Len    =    $-UnknownMsg2
  53.  
  54. NormalMsg1    DB    'Normal termination with exit code ('
  55. NormalMsg1Len    =    $-NormalMsg1
  56. NormalMsg2    DB    ')',13,10
  57. NormalMsg2Len    =    $-NormalMsg2
  58.  
  59. ;
  60. ; -------------------- DOS errors --------------------
  61. ;
  62. Err1Msg        DB    'DOS: Invalid function number.'
  63. Err1Len        =    $-Err1Msg
  64. Err1Expln    DB    '    Possible cause:',13,10,'    You made a '
  65.         DB    'call to an nonexistent DOS function.',13,10
  66. Err1ELen    =    $-Err1Expln
  67. Err2Msg        DB    'DOS: File not found.',13,10
  68. Err2Len        =    $-Err2Msg
  69. Err2Expln    DB    '    Possible cause:',13,10,'    Name assigned'
  70.         DB    ' to file variable passed to Reset, Append, Re'
  71.         DB    'name, or Erase',13,10,'    does not specify a'
  72.         DB    'n existing file.',13,10
  73. Err2ELen    =    $-Err2Expln
  74. ;
  75. Err3Msg        DB    'DOS: Path not found.',13,10
  76. Err3Len        =    $-Err3Msg
  77. Err3Expln    DB    '    Possible causes:',13,10,'    1) Name assi'
  78.         DB    'gned to file variable passed to Reset, Rewrit'
  79.         DB    'e, Append or',13,10,'       Erase is invalid '
  80.         DB    'or specifies a nonexistent subdirectory.',13
  81.         DB    10,'    2) Path passed to ChDir, MkDir, or RmD'
  82.         DB    'ir is invalid or specifies a',13,10,'       n'
  83.         DB    'onexistent directory',13,10
  84. Err3ELen    =    $-Err3Expln
  85. ;
  86. Err4Msg        DB    'DOS: Too many open files.',13,10
  87. Err4Len        =    $-Err4Msg
  88. Err4Expln    DB    '    Possible causes:',13,10,'    Reset, Rewri'
  89.         DB    'te or Append could not open file because ther'
  90.         DB    'e are too many',13,10,'    files opened.  DOS'
  91.         DB    ' never allows more than 15 open files per pro'
  92.         DB    'cess.  If',13,10,'    this error occurred wit'
  93.         DB    'h less than 15 files, this may indicate that '
  94.         DB    'the',13,10,'    CONFIG.SYS file does not incl'
  95.         DB    'ude a FILES=xx entry or that the entry',13,10
  96.         DB    '    specifies too few files.  To remedy this '
  97.         DB    'problem, increase this value to',13,10,'    p'
  98.         DB    'roblem, increase this value to a larger value'
  99.         DB    ', for example 20.',13,10
  100. Err4ELen    =    $-Err4Expln
  101. ;
  102. Err5Msg        DB    'DOS: File access denied.',13,10
  103. Err5Len        =    $-Err5Msg
  104. Err5Expln    DB    '    Possible causes:',13,10,'    1) Reset or '
  105.         DB    'Append failed because FileMode allows writing'
  106.         DB    ' and the name',13,10,'       assigned to the '
  107.         DB    'file variable specifies a directory or read-o'
  108.         DB    'nly file.',13,10,'    2) Rewrite failed becau'
  109.         DB    'se the directory is full or the file name is'
  110.         DB    13,10,'       already used by a directory or a'
  111.         DB    ' read-only file.',13,10,'    3) Rename failed'
  112.         DB    ' because the file variable was assigned to a '
  113.         DB    'directory,',13,10,'       or because the new '
  114.         DB    'name specified specifies an existing file.',13
  115.         DB    10,'    4) Erase cannot be used with a directo'
  116.         DB    'ry nor can it be used with a',13,10,'       r'
  117.         DB    'ead-only file.',13,10,'    5) MkDir encounter'
  118.         DB    'd a problem because',13,10,'       a) directo'
  119.         DB    'ry name already exists as a file name or dire'
  120.         DB    'ctory name.',13,10,'       b) there is no mor'
  121.         DB    'e room in the parent directory.',13,10,'     '
  122.         DB    '  c) the path specified a device.',13,10,'   '
  123.         DB    ' 6) RmDir encounterd a problem because',13,10
  124.         DB    '       a) directory specified is not empty.'
  125.         DB    13,10,'       b) the path does not specify a d'
  126.         DB    'irectory.',13,10,'       c) the path specifie'
  127.         DB    's the root directory.',13,10,'    7) You trie'
  128.         DB    'd reading from a file that was not open for r'
  129.         DB    'eading.',13,10,'    8) You tried writing to a'
  130.         DB    ' file that was not open for writing',13,10
  131. Err5ELen    =    $-Err6Expln
  132. ;
  133. Err6Msg        DB    'DOS: Invalid file handle.',13,10
  134. Err6Len        =    $-Err6Msg
  135. Err6Expln    DB    '    Possible causes:',13,10,'    This error i'
  136.         DB    's reported if an invalid file handle is passe'
  137.         DB    'd to a DOS system',13,10,'    call.  It shoul'
  138.         DB    'd never occur; if it does, it is an indicatio'
  139.         DB    'n that the',13,10,'    file variable was some'
  140.         DB    'how trashed.',13,10
  141. Err6ELen    =    $-Err6Expln
  142. ;
  143. Err12Msg    DB    'DOS: Invalid file access code.',13,10
  144. Err12Len    =    $-Err12Msg
  145. Err12Expln    DB    '    Possible causes:',13,10,'    Reset or App'
  146.         DB    'end encountered difficulty because the value '
  147.         DB    'of FileMode is',13,10,'    invalid.',13,10
  148. Err12ELen    =    $-Err12Expln
  149. ;
  150. Err15Msg    DB    'DOS: Bad drive number.',13,10
  151. Err15Len    =    $-Err15Msg
  152. Err15Expln    DB    '    Possible causes:',13,10,'    GetDir faile'
  153.         DB    'd because the drive number specified is inval'
  154.         DB    'id.',13,10
  155. Err15ELen    =    $-Err15Expln
  156. ;
  157. Err16Msg    DB    'DOS: Cannot remove current directory.',13,10
  158. Err16Len    =    $-Err16Msg
  159. Err16Expln    DB    '    Possible causes:',13,10,'    Path specifi'
  160.         DB    'ed for RmDir is the current directory.',13,10
  161. Err16ELen    =    $-Err16Expln
  162. ;
  163. Err17Msg    DB    'DOS: Cannot rename across drives.',13,10
  164. Err17Len    =    $-Err17Msg
  165. Err17Expln    DB    '    Possible causes:',13,10,'    You cannot r'
  166.         DB    'ename across disk drives.'
  167. Err17ELen    =    $-Err17Expln
  168.  
  169. ;
  170. ; -------------------- I/O errors --------------------
  171. ;
  172. Err100Msg    DB    'I/O: Disk read error.',13,10
  173. Err100Len    =    $-Err100Msg
  174. Err100Expln    DB    '    Possible causes:',13,10,'    A read was a'
  175.         DB    'ttempted past end of file.',13,10
  176. Err100ELen    =    $-Err100Expln
  177. ;
  178. Err101Msg    DB    'I/O: Disk write error.',13,10
  179. Err101Len    =    $-Err101Msg
  180. Err101Expln    DB    '    Possible causes:',13,10,'    Disk is full'
  181.         DB    '.',13,10
  182. Err101ELen    =    $-Err101Expln
  183. ;
  184. Err102Msg    DB    'I/O: File not assigned.',13,10
  185. Err102Len    =    $-Err102Msg
  186. Err102Expln    DB    '    Possible causes:',13,10,'    Reset, Rewri'
  187.         DB    'te, Append, Rename, or Erase failed because t'
  188.         DB    'he file',13,10,'    variable has not been ass'
  189.         DB    'igned a name through Assign.',13,10
  190. Err102ELen    =    $-Err102Expln
  191. ;
  192. Err103Msg    DB    'I/O: File not open.',13,10
  193. Err103Len    =    $-Err103Msg
  194. Err103Expln    DB    '    Possible causes:',13,10,'    A file opera'
  195.         DB    'tion was attempted when file was not open.',13
  196.         DB    10
  197. Err103ELen    =    $-Err103Expln
  198. ;
  199. Err104Msg    DB    'I/O: File not open for input.',13,10
  200. Err104Len    =    $-Err104Msg
  201. Err104Expln    DB    '    Possible causes:',13,10,'    File cannot '
  202.         DB    'be read when it is not opened for input.',13
  203.         DB    10
  204. Err104ELen    =    $-Err104Expln
  205. ;
  206. Err105Msg    DB    'I/O: File not open for output.',13,10
  207. Err105Len    =    $-Err105Msg
  208. Err105Expln    DB    '    Possible causes:',13,10,'    File cannot '
  209.         DB    'be written to when it is not opened for outpu'
  210.         DB    't.',13,10
  211. Err105ELen    =    $-Err105Expln
  212. ;
  213. Err106Msg    DB    'I/O: Invalid numeric format.',13,10
  214. Err106Len    =    $-Err106Msg
  215. Err106Expln    DB    '    Possible causes:',13,10,'    Read or Read'
  216.         DB    'ln tried to read a numeric variable, and the '
  217.         DB    'input did not',13,10,'    conform to proper n'
  218.         DB    'umeric format.',13,10
  219. Err106ELen    =    $-Err106Expln
  220. ;
  221. ; -------------------- Critical errors --------------------
  222. ;
  223. Err150Msg    DB    'Critical Error: Disk is write-protected.',13
  224.         DB    10
  225. Err150Len    =    $-Err150Msg
  226. Err150Expln    DB    'See DOS manual for details.',13,10
  227. Err150ELen    =    $-Err150Expln
  228. ;
  229. Err151Msg    DB    'Critical Error: Unknown unit.',13,10
  230. Err151Len    =    $-Err151Msg
  231. Err151Expln    DB    'See DOS manual for details.',13,10
  232. Err151ELen    =    $-Err151Expln
  233. ;
  234. Err152Msg    DB    'Critical Error: Drive not ready.',13,10
  235. Err152Len    =    $-Err152Msg
  236. Err152Expln    DB    'See DOS manual for details.',13,10
  237. Err152ELen    =    $-Err152Expln
  238. ;
  239. Err153Msg    DB    'Critical Error: Unknown command.',13,10
  240. Err153Len    =    $-Err153Msg
  241. Err153Expln    DB    'See DOS manual for details.',13,10
  242. Err153ELen    =    $-Err153Expln
  243. ;
  244. Err154Msg    DB    'Critical Error: CRC error in data.',13,10
  245. Err154Len    =    $-Err154Msg
  246. Err154Expln    DB    'See DOS manual for details.',13,10
  247. Err154ELen    =    $-Err154Expln
  248. ;
  249. Err155Msg    DB    'Critical Error: Bad drive request structure l'
  250.         DB    'ength.',13,10
  251. Err155Len    =    $-Err155Msg
  252. Err155Expln    DB    'See DOS manual for details.',13,10
  253. Err155ELen    =    $-Err155Expln
  254. ;
  255. Err156Msg    DB    'Critical Error: Disk seek error.',13,10
  256. Err156Len    =    $-Err156Msg
  257. Err156Expln    DB    'See DOS manual for details.',13,10
  258. Err156ELen    =    $-Err156Expln
  259. ;
  260. Err157Msg    DB    'Critical Error: Unknown media type.',13,10
  261. Err157Len    =    $-Err157Msg
  262. Err157Expln    DB    'See DOS manual for details.',13,10
  263. Err157ELen    =    $-Err157Expln
  264. ;
  265. Err158Msg    DB    'Critical Error: Sector not found.',13,10
  266. Err158Len    =    $-Err158Msg
  267. Err158Expln    DB    'See DOS manual for details.',13,10
  268. Err158ELen    =    $-Err158Expln
  269. ;
  270. Err159Msg    DB    'Critical Error: Printer out of paper.',13
  271.         DB    10
  272. Err159Len    =    $-Err159Msg
  273. Err159Expln    DB    'See DOS manual for details.',13,10
  274. Err159ELen    =    $-Err159Expln
  275. ;
  276. Err160Msg    DB    'Critical Error: Device write fault.',13,10
  277. Err160Len    =    $-Err160Msg
  278. Err160Expln    DB    'See DOS manual for details.',13,10
  279. Err160ELen    =    $-Err160Expln
  280. ;
  281. Err161Msg    DB    'Critical Error: Device read fault.',13,10
  282. Err161Len    =    $-Err161Msg
  283. Err161Expln    DB    'See DOS manual for details.',13,10
  284. Err161ELen    =    $-Err161Expln
  285. ;
  286. Err162Msg    DB    'Critical Error: Hardware failure.',13,10
  287. Err162Len    =    $-Err162Msg
  288. Err162Expln    DB    'See DOS manual for details.',13,10
  289. Err162ELen    =    $-Err162Expln
  290. ;
  291. ; -------------------- Fatal errors --------------------
  292. ;
  293. Err200Msg    DB    'Fatal: Division by zero.',13,10
  294. Err200Len    =    $-Err200Msg
  295. Err200Expln    DB    ''
  296. Err200ELen    =    $-Err200Expln
  297. ;
  298. Err201Msg    DB    'Fatal: Range check error.',13,10
  299. Err201Len    =    $-Err201Msg
  300. Err201Expln    DB    '    Possible causes:',13,10,'    1) Index exp'
  301.         DB    'ression of an array qualifier was out of rang'
  302.         DB    'e.',13,10,'    2) An attempt was made to assi'
  303.         DB    'gn an out of range value to a variable.',13
  304.         DB    10,'    3) An attempt was made to pass an out '
  305.         DB    'of range value as a parameter to a',13,10,'  '
  306.         DB    '     procedure or function.',13,10
  307. Err201ELen    =    $-Err201Expln
  308. ;
  309. Err202Msg    DB    'Fatal: Stack overflow error.',13,10
  310. Err202Len    =    $-Err202Msg
  311. Err202Expln    DB    '    Possible causes:',13,10,'    This error i'
  312.         DB    's reported on entry to a procedure or functio'
  313.         DB    'n compiled in the',13,10,'    {$S+} state whe'
  314.         DB    'n there is not enough stack space to allocate'
  315.         DB    ' the',13,10,'    subprogram''s local variable'
  316.         DB    's.  Increase the size of the stack by using'
  317.         DB    13,10,'    the {$M #,#,#} compiler directive.'
  318.         DB    13,10
  319. Err202ELen    =    $-Err202Expln
  320. ;
  321. Err203Msg    DB    'Fatal: Heap overflow error.',13,10
  322. Err203Len    =    $-Err203Msg
  323. Err203Expln    DB    '    Possible causes:',13,10,'    New or GetMe'
  324.         DB    'm request failed.',13,10
  325. Err203ELen    =    $-Err203Expln
  326. ;
  327. Err204Msg    DB    'Fatal: Invalid pointer operation.',13,10
  328. Err204Len    =    $-Err204Msg
  329. Err204Expln    DB    '    Possible causes:',13,10,'    a) Pointer p'
  330.         DB    'assed to Dispose or FreeMem is NIL.',13,10,' '
  331.         DB    '   b) Pointer passed to Dispose or FreeMem po'
  332.         DB    'ints outside heap area.',13,10,'    c) Free l'
  333.         DB    'ist could not be expanded.',13,10
  334. Err204ELen    =    $-Err204Expln
  335. ;
  336. Err205Msg    DB    'Fatal: Floating point overflow.',13,10
  337. Err205Len    =    $-Err205Msg
  338. Err205Expln    DB    '    Possible causes:',13,10,'    A floating-'
  339.         DB    'point operation produced a number too large '
  340.         DB    'for Turbo',13,10,'    Pascal or the numeric '
  341.         DB    'coprocessor (if any) to handle.',13,10
  342. Err205ELen    =    $-Err205Expln
  343. ;
  344. Err206Msg    DB    'Fatal: Floating point underflow.',13,10
  345. Err206Len    =    $-Err206Msg
  346. Err206Expln    DB    '    Possible causes:',13,10,'    A floating-'
  347.         DB    'point operation produced an underflow.  This'
  348.         DB    ' error is',13,10,'    only reported if you a'
  349.         DB    're using the 8087 numeric coprocessor with'
  350.         DB    13,10,'    a control word that unmasks underf'
  351.         DB    'low exceptions.  By default,',13,10,'    an '
  352.         DB    'underflow causes a result of zero to be retu'
  353.         DB    'rned.',13,10
  354. Err206ELen    =    $-Err206Expln
  355. ;
  356. Err207Msg    DB    'Fatal: Invalid floating point operation.',13
  357.         DB    10
  358. Err207Len    =    $-Err207Msg
  359. Err207Expln    DB    '    Possible causes:',13,10,'    a) Real valu'
  360.         DB    'e passed to Trunc or Round not in range -21,4'
  361.         DB    '74,843,648 to',13,10,'       21,474,843,647.'
  362.         DB    13,10,'    b) Argument passed to Sqrt was nega'
  363.         DB    'tive.',13,10,'    c) The 8087''s stack overfl'
  364.         DB    'owed',13,10
  365. Err207ELen    =    $-Err207Expln
  366. ;
  367. ; Turbo Pascal Version 5.0 error message
  368. ;
  369. Err208Msg    DB    'Fatal: Overlay manager not installed.',13,10
  370. Err208Len    =    $-Err208Msg
  371. Err208Expln    DB    '    Possible causes:',13,10,'    Your program'
  372.         DB    ' is calling an overlaid procedure or function'
  373.         DB    ', but the',13,10,'    overlay manager is not '
  374.         DB    'installed.  Most likely, you are not calling'
  375.         DB    13,10,'    OvrInit, or the call to OvrInit fai'
  376.         DB    'led.  Note that, if you have',13,10,'    init'
  377.         DB    'ialization code in any of your overlaid units'
  378.         DB    ', you must create an',13,10,'    additional n'
  379.         DB    'on-overlaid unit which calls OvrInit, and use'
  380.         DB    ' that unit',13,10,'    before any of the over'
  381.         DB    'laid units.  For a complete description of th'
  382.         DB    'e',13,10,'    overlay manager, refer to Chapt'
  383.         DB    'er 6 in the User''s Guide, "Using Overlays."'
  384.         DB    13,10
  385. Err208ELen    =    $-Err208Expln
  386. ;
  387. Err209Msg    DB    'Fatal: Overlay file read error.',13,10
  388. Err209Len    =    $-Err209Msg
  389. Err209Expln    DB    '    Possible causes:',13,10,'    A read error'
  390.         DB    ' occurred when the overlay manager tried to r'
  391.         DB    'ead an overlay',13,10,'    file.',13,10
  392. Err209ELen    =    $-Err209Expln
  393.  
  394. ;
  395. ; Turbo Pascal Version 5.5 error messages
  396. ;
  397. Err210Msg    DB    'Fatal: Object not initialized.',13,10
  398. Err210Len    =    $-Err210Msg
  399. Err210Expln    DB    '    Possible causes:',13,10,'    With range-c'
  400.         DB    'hecking on, you made a call to an object''s v'
  401.         DB    'irtual',13,10,'    method, before the object '
  402.         DB    'had been initialized via a constructor',13,10
  403.         DB    '    call.',13,10
  404. Err210ELen    =    $-Err210Expln
  405. ;
  406. ; Turbo Pascal Version 6.0 error messages.
  407. ;
  408. Err211Msg    DB    'Fatal: Call to abstract method'
  409. Err211Len    =    $-Err211Msg
  410. Err211Expln    DB    '    Possible Causes:',13,10,'    This error i'
  411.         DB    's generated by the Abstract procedure in the '
  412.         DB    'Objects unit; it',13,10,'    indicates that y'
  413.         DB    'our program tried to execute an abstract virt'
  414.         DB    'ual method.',13,10,'    When an object type c'
  415.         DB    'ontains one or more abstract methods it is ca'
  416.         DB    'lled an',13,10,'    abstract object type.  It'
  417.         DB    ' is an error to instatiate objects of an abst'
  418.         DB    'ract',13,10,'    type -- abstract types exist'
  419.         DB    ' only so that you can inherit from them and'
  420.         DB    13,10,'    override the abstract methods.',13
  421.         DB    10,13,10,'    For example, the Compare method '
  422.         DB    'of the TSortedCollection type in the',13,10
  423.         DB    '    Objects unit is abstract, indicating that'
  424.         DB    ' to implement a sorted',13,10,'    collection'
  425.         DB    ' you must create an object type that inherits'
  426.         DB    ' from',13,10,'    TSortedCollection and overr'
  427.         DB    'ides the Compare method.',13,10
  428. Err211ELen    =    $-Err211Expln
  429.  
  430. Err212Msg    DB    'Fatal: Stream registration error'
  431. Err212Len    =    $-Err212Msg
  432. Err212Expln    DB    '    Possible cause:',13,10,'    This error is'
  433.         DB    ' generated by the RegisterType procedure in t'
  434.         DB    'he Objects unit',13,10,'    indicating that o'
  435.         DB    'ne of the following errors have occurred:',13
  436.         DB    10,'        1) The stream registration record '
  437.         DB    'does not reside in the data segment.',13,10
  438.         DB    '        2) The ObjType field of the stream re'
  439.         DB    'gistration record is zero.',13,10,'        3)'
  440.         DB    ' The type has already been registered.',13,10
  441.         DB    '        4) Another type with the same ObjType'
  442.         DB    ' value already exits.',13,10
  443. Err212ELen    =    $-Err212Expln
  444.  
  445. Err213Msg    DB    'Fatal: Collection index out of range.'
  446. Err213Len    =    $-Err213Msg
  447. Err213Expln    DB    '    Possible cause:',13,10,'    The index pas'
  448.         DB    'sed to a method of a TCollection is out of ra'
  449.         DB    'nge.',13,10
  450. Err213ELen    =    $-Err213Expln
  451.  
  452. Err214Msg    DB    'Fatal: Collection overflow error'
  453. Err214Len    =    $-Err214Msg
  454. Err214Expln    DB    '    Possible cause:',13,10,'    The error is '
  455.         DB    'reported by a TCollection if an attempt is ma'
  456.         DB    'de to add an',13,10,'    element when the col'
  457.         DB    'lection cannot be expanded.',13,10
  458. Err214ELen    =    $-Err214Expln
  459. ;
  460. ;
  461. ; ==================== Message table ====================
  462. ;
  463. MsgStruc    STRUC
  464.     Num    DW    ?
  465.     MsgPtr    DW    ?
  466.     MsgLen    DW    ?
  467.     ExpPtr    DW    ?
  468.     ExpLen    DW    ?
  469. MsgStruc    ENDS
  470. ;
  471.  
  472. ErrTbl        =    $
  473. ; -------------------- DOS errors --------------------
  474. IRP    N,<1,2,3,4,5,6,12,15,16,17>
  475.     MsgStruc <&N,Err&N&Msg,Err&N&Len,Err&N&Expln,Err&N&ELen>
  476.     ENDM
  477. ; -------------------- I/O errors --------------------
  478. IRP    N,<100,101,102,103,104,105,106>
  479.     MsgStruc <&N,Err&N&Msg,Err&N&Len,Err&N&Expln,Err&N&ELen>
  480.     ENDM
  481. ; -------------------- Critical errors --------------------
  482. IRP    N,<150,151,152,153,154,155,156,157,158,159,160,161,162>
  483.     MsgStruc <&N,Err&N&Msg,Err&N&Len,Err&N&Expln,Err&N&ELen>
  484.     ENDM
  485. ; -------------------- Fatal errors --------------------
  486. IRP    N,<200,201,202,203,204,205,206,207>
  487.     MsgStruc <&N,Err&N&Msg,Err&N&Len,Err&N&Expln,Err&N&ELen>
  488.     ENDM
  489.     ; version 5.0
  490.     MsgStruc <208,Err208Msg,Err208Len,Err208Expln,Err208ELen>
  491.     MsgStruc <209,Err209Msg,Err209Len,Err209Expln,Err209ELen>
  492.     ; version 5.5
  493.     MsgStruc <210,Err210Msg,Err210Len,Err210Expln,Err210ELen>
  494.     ; version 6.0
  495.     MsgStruc <211,Err211Msg,Err211Len,Err211Expln,Err211ELen>
  496.     MsgStruc <212,Err212Msg,Err212Len,Err212Expln,Err212ELen>
  497.     MsgStruc <213,Err213Msg,Err213Len,Err213Expln,Err213ELen>
  498.     MsgStruc <214,Err214Msg,Err214Len,Err214Expln,Err214ELen>
  499.  
  500. NumErr    = ($-ErrTbl) / (SIZE MsgStruc)
  501.  
  502. ErrorMessage    PROC FAR
  503.     PUBLIC    ErrorMessage
  504.     ; Restore exit procedure pointer
  505.     uses    ds
  506.     mov    ax,ds
  507.     mov    es,ax
  508.     mov    di,OFFSET ExitProc
  509.     mov    si,OFFSET ExitSave
  510.     cld
  511.     movsw                ; copy pointer
  512.     movsw                ;
  513.     ;--------------------------------------------------------------
  514.     ; Get to new line on display
  515.     ;--------------------------------------------------------------
  516.     mov    ax,cs
  517.     mov    ds,ax
  518.     mov    cx,NewLineLen
  519.     mov    dx,OFFSET NewLine
  520.     mov    ah,40h
  521.     mov    bx,0001h
  522.     int    21h
  523.     ;--------------------------------------------------------------
  524.     ; see if exit ptr is zero
  525.     ;--------------------------------------------------------------
  526.     pop    ds        ; restore data segment value
  527.     push    ds
  528.     les    di,[ErrorAddr]
  529.     mov    ax,es
  530.     or    ax,di
  531.     jnz    NonZeroError
  532.     ;--------------------------------------------------------------
  533.     ; No error, but look at exit code
  534.     ;--------------------------------------------------------------
  535.     mov    [Msg1],OFFSET NormalMsg1
  536.     mov    [Msg1Len],NormalMsg1Len
  537.     mov    [Msg2],OFFSET NormalMsg2
  538.     mov    [Msg2Len],NormalMsg2Len
  539.     jmp    MsgWithNum
  540.     ;--------------------------------------------------------------
  541.     ; Non-zero error address, means we have an error
  542.     ;--------------------------------------------------------------
  543. NonZeroError:
  544.     mov    si,(OFFSET ErrTbl)-(SIZE MsgStruc)
  545.     mov    ax,[ExitCode]
  546.     mov    cx,NumErr
  547. FindLoop:
  548.     add    si,SIZE MsgStruc
  549.     cmp    ax,[MsgStruc (cs:si).Num]
  550.     loopne    FindLoop
  551.     je    PrintErrMsg
  552.     ;--------------------------------------------------------------
  553.     ; Non-zero error address with unknown error code
  554.     ;--------------------------------------------------------------
  555. DontKnow:
  556.     mov    [Msg1],OFFSET UnknownMsg1
  557.     mov    [Msg1Len],UnknownMsg1Len
  558.     mov    [Msg2],OFFSET UnknownMsg2
  559.     mov    [Msg2Len],UnknownMsg2Len
  560.     ;--------------------------------------------------------------
  561.     ; Print message with error code
  562.     ;--------------------------------------------------------------
  563. MsgWithNum:
  564.     ; print first part of msg
  565.     mov    cx,[Msg1Len]
  566.     mov    dx,[Msg1]
  567.     mov    ax,cs
  568.     mov    ds,ax
  569.     mov    ah,40h
  570.     mov    bx,0001h
  571.     int    21h
  572.     pop    ds                ; restore data segment
  573.     push    ds
  574.     mov    ax,[ExitCode]
  575.     mov    bx,(OFFSET Buffer)+(BufferSize)
  576.     xor    cx,cx
  577.     mov    si,10
  578. Cnvrt:    dec    bx
  579.     xor    dx,dx
  580.     inc    cx
  581.     div    si
  582.     add    dx,'0'
  583.     mov    [bx],dl
  584.     or    ax,ax
  585.     jnz    Cnvrt
  586.     ; print exit code number
  587.     mov    dx,bx
  588.     mov    ah,40h
  589.     mov    bx,0001h
  590.     int    21h
  591.     ; print tail end of msg
  592.     mov    cx,[Msg2Len]
  593.     mov    dx,[Msg2]
  594.     mov    ax,cs
  595.     mov    ds,ax
  596.     mov    ah,40h
  597.     mov    bx,0001h
  598.     int    21h
  599.     jmp    Done
  600.     ;--------------------------------------------------------------
  601.     ; Print error message selected from search loop
  602.     ;--------------------------------------------------------------
  603. PrintErrMsg:
  604.     mov    ax,cs
  605.     mov    ds,ax
  606.     mov    ah,40h
  607.     mov    bx,0001h
  608.     mov    dx,[MsgStruc (cs:si).MsgPtr]
  609.     mov    cx,[MsgStruc (cs:si).MsgLen]
  610.     int    21h
  611.     pop    ds
  612.     push    ds
  613.     test    [VerboseMsg],0ffh
  614.     jz    Done
  615.     ; Print explaination string
  616.     mov    ax,cs
  617.     mov    ds,ax
  618.     mov    ah,40h
  619.     mov    bx,0001h
  620.     mov    dx,[MsgStruc (cs:si).ExpPtr]
  621.     mov    cx,[MsgStruc (cs:si).ExpLen]
  622.     int    21h
  623.     ;
  624.     ;--------------------------------------------------------------
  625.     ;
  626. Done:
  627.     ret
  628. ErrorMessage    ENDP
  629.  
  630. END
  631.